package com.example.tests;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import org.testng.annotations.Test;
import com.example.fw.GroupObject;
import com.example.fw.Groups;

public class GroupModificationTests extends TestBase{
	
	@Test(dataProvider = "randomGroups", dataProviderClass = GroupDataGenerator.class) 
	public void testGroupModification(GroupObject validGroup) throws Exception {
		Groups oldList = app.getHibernateHelper().getGroups();
		GroupObject someGroup = oldList.getSomeGroup();
		app.getGroupHelper().modifyGroup(someGroup , validGroup);
		Groups newList = app.getHibernateHelper().getGroups();
	verifyGroupModified(oldList, validGroup, newList);
	assertThat(newList, equalTo(oldList.withoutRemoved(someGroup).withAdded(validGroup)));

	
	
	}
	@Test 
	public void testUiConfirmsDB(){
		Groups dbList = app.getHibernateHelper().getGroups();
		Groups uiList = app.getGroupHelper().getGroups();
		assertThat(dbList, equalTo(uiList));
	}
		

}
